﻿//-----------------------------------------------------------------------
// <copyright file="ExpectedRuleViolationAttribute.cs">
//     Copyright (c) Nicole Calinoiu. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Reflection;

using Microsoft.VisualStudio.CodeAnalysis.Extensibility;

namespace Bordecal.FxCop.Sdk.Testing
{
	/// <summary>
	/// Indicates that an FxCop violation is expected for testing purposes.
	/// </summary>
	[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
	public sealed class ExpectedRuleViolationAttribute : Attribute
	{
		#region Fields
		
		private readonly string _category;
		private readonly string _checkId;
		private readonly string _ruleName;

		private readonly string _fixCategories;
		private readonly string _messageLevel;
		private readonly int _certainty;

		private readonly string _resolution;

		#endregion

		#region Constructors
		
		/// <summary>
		/// Initializes a new instance of the <see cref="ExpectedRuleViolationAttribute" /> class.
		/// </summary>
		/// <param name="category">The rule category.</param>
		/// <param name="checkId">The rule identifier.</param>
		/// <param name="ruleName">The rule name.</param>
		/// <param name="fixCategories">The violation fix categories.</param>
		/// <param name="messageLevel">The violation message level.</param>
		/// <param name="certainty">The violation certainty.</param>
		/// <param name="resolution">The violation resolution.</param>
		public ExpectedRuleViolationAttribute(
			string category,
			string checkId,
			string ruleName,
			string fixCategories,
			string messageLevel,
			int certainty,
			string resolution)
		{
			if (category == null)
			{
				throw new ArgumentNullException("category");
			}

			if (checkId == null)
			{
				throw new ArgumentNullException("checkId");
			}

			if (ruleName == null)
			{
				throw new ArgumentNullException("ruleName");
			}

			if (resolution == null)
			{
				throw new ArgumentNullException("resolution");
			}

			this._category = category;
			this._checkId = checkId;
			this._ruleName = ruleName;
			this._fixCategories = fixCategories;
			this._messageLevel = messageLevel;
			this._certainty = certainty;
			this._resolution = resolution;
		}

		#endregion

		#region Properties

		/// <summary>
		/// Gets the rule category.
		/// </summary>
		public string Category
		{
			get
			{
				return this._category;
			}
		}

		/// <summary>
		/// Gets the rule identifier.
		/// </summary>
		public string CheckId
		{
			get
			{
				return this._checkId;
			}
		}

		/// <summary>
		/// Gets the name of the rule.
		/// </summary>
		public string RuleName
		{
			get
			{
				return this._ruleName;
			}
		}

		/// <summary>
		/// Gets the fix categories for the violation.
		/// </summary>
		public string FixCategories
		{
			get
			{
				return this._fixCategories;
			}
		}

		/// <summary>
		/// Gets the message level for the violation.
		/// </summary>
		public string MessageLevel
		{
			get
			{
				return this._messageLevel;
			}
		}

		/// <summary>
		/// Gets the certainty for the violation.
		/// </summary>
		public int Certainty
		{
			get
			{
				return this._certainty;
			}
		}

		/// <summary>
		/// Gets the resolution for the violation.
		/// </summary>
		public string Resolution
		{
			get
			{
				return this._resolution;
			}
		}

		/// <summary>
		/// Gets or sets the name of the file in which the violation occurs.
		/// </summary>
		public string FileName { get; set; }

		/// <summary>
		/// Gets or sets the line number on which the violation occurs.
		/// </summary>
		public int LineNumber { get; set; }

		/// <summary>
		/// Gets or sets the violation identifier.
		/// </summary>
		public string MessageId { get; set; }

		#endregion
	}
}